package com.ykl.base.restful;

import com.ykl.base.service.EntityService;

import java.util.Optional;

public class BasicEntityServiceCtrl<T> extends GeneralCtrl {

    protected EntityService<T> serv;

    protected BasicEntityServiceCtrl(EntityService<T> service){
        this.serv = service;
    }

    /**
     * 增加或修改机房接口.
     */
    protected T save(T target){
        return serv.save(target);
    }

    /**
     * 根据id查找.
     * @param id 要查找的对象的id.
     * @return 结果.
     */
    protected Optional<T> findById(String id){
        return serv.findById(id);
    }

    /**
     * 根据id
     * @param id 要删除的对象的id.
     */
    protected void deleteById(String id){
        serv.deleteById(id);
    }

}
